<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>餐桌添加</title>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script type="text/javascript" src="../layui/layui.js"></script>
</head>
<body>
<div class="container">
    <form class="layui-form" lay-filter="formTest" id="addForm">
        <div class="layui-form-item" style="margin-top: 20px">
            <label class="layui-form-label">
                桌号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="tableId" name="tableId" required lay-verify="required"
                       placeholder="请输入桌号" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" key="set-mine" lay-filter="save" lay-submit>
                保存
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var layer = layui.layer;
        //监听提交
        form.on('submit(save)', function (data) {
            var tableId = data.field.tableId;//表格数据
            $.post("../addTable.do", {"tableId": tableId}, function (data) {
                if (data.success) {
                    layer.alert(data.message, {icon: 6}, function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        parent.layui.table.reload('DingTable');
                    });
                } else {
                    layer.alert(data.message, {icon: 3}, function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                    });
                }
            }, "json");
            return false;
        });
    });

</script>
</body>
</html>